package sysu.el.graph.undi;

import sysu.el.array.ints.ArrInt;
import sysu.el.graph.Edge;
import sysu.el.graph.GraphConstants;

/**
 * The design is specified to the immutable graphtopo.
 * There of cource exists some kind of modification in graph, when the topo changed,
 * a lot of things change, even here the graph topo. We can new one graph topo, or 
 * use the reset() function whose status is "Todo"
 * @author Edwin Lee
 *
 */

public class UndiGTX extends UndiGT{

	public UndiGTX(int num, int wei[][]){
		super(num, wei);
	}
	
	public UndiGTX(int nodeNum, int edgeNum, Edge[] edgeList) {
		super(nodeNum, edgeNum, edgeList);
	}
	
	public UndiGTX(int edgeNum, Edge[] edgeList) {
		super(edgeNum, edgeList);
	}

	public int adjWei[][];
//	@Override
//	public void establishDataFromWeight(int wei[][]){
//		/**
//		 * Make the adjNodes second dimension empty instead of give them fixed max len
//		 * to avoid much garbage collection
//		 * Reuse the ArrInt
//		 */
//		ArrInt tmpArr = new ArrInt(this.nodeNum);
//		for (int i=0; i<this.nodeNum; i++){
//			tmpArr.reset();
//			for (int j=0; j<this.nodeNum; j++){
//				this.w[i][j] = wei[i][j];
//				if (wei[i][j] != GraphConstants.NULL_EDGE)	tmpArr.add(j);
//			}
//			
//			this.adjNodes[i] = new int[tmpArr.counter];
//			this.adjWei[i] = new int[tmpArr.counter];
//			for (int j=0; j<tmpArr.counter; j++){
//				this.adjNodes[i][j] = tmpArr.list[j];
//				this.adjWei[i][j] = this.w[i][tmpArr.list[j]];
//			}
//		}
//	}
//	
//	
//	@Override
//	public void establishDataFromEdgeList(Edge edgeList[]) {
//		this.adjNodes = new int[nodeNum][nodeNum];
//		// Diff
//		this.adjWei = new int[nodeNum][nodeNum];
//		// Diff
//		/** Why don't we use ArrInt[]?
//		 *  Because we have to setup a loop to new ArrInt[i]
//		 */
//		int [] adjDegree= new int[nodeNum];
//
//		for (int i=0; i<edgeNum; i++){
//			int s = edgeList[i].s;
//			int e = edgeList[i].e;
//			adjNodes[s][adjDegree[s] ++ ] = e;
//			adjNodes[e][adjDegree[e] ++ ] = s;
//			// Diff
//			this.adjWei[s][adjDegree[s]] = edgeList[i].w;
//			this.adjWei[e][adjDegree[e]] = edgeList[i].w;
//			// Diff
//			this.w[s][e] = edgeList[i].w;
//		}
//		
//		for (int i=0; i<nodeNum; i++){
//			// Diff
//			int len = adjDegree[i];
//			int[] a = new int[len];
//			int[] aw= new int[len];
//			for (int j=0; j<len; j++){
//				a[j] = this.adjNodes[i][j];
//				aw[j]= this.adjWei[i][j];
//			}
//			this.adjNodes[i] = a;
//			this.adjWei[i] = aw;
//			// Dif
//		}
//	}

}
